package file;

import java.io.*;
import java.util.*;

public class Crea {

	public static void main(String[] args) throws IOException {

		DataOutputStream dos = new DataOutputStream(new FileOutputStream(
				"c:\\poo-file\\f3.dat"));
		System.out.print("fornisci una serie di interi 1 pre linea");
		Scanner sc = new Scanner(System.in);
		for (;;) {
			System.out.print("int >");
			String input = sc.nextLine();
			if (input.length() == 0)
				break;
			dos.writeInt(Integer.parseInt(input));
		}
		dos.close();

		DataInputStream dis = new DataInputStream(new FileInputStream(
				"c:\\poo-file\\f3.dat"));
		System.out.println();
		System.out.println("Contenuto del file");
		int x = 0;
		for (;;) {
			try {
				x = dis.readInt();

			} catch (EOFException e) {
				break;
			}
			System.out.println(x);
		}// for
		dis.close();

	}

}
